package com.source.boot01.controller;

import com.source.boot01.domain.Student;
import com.source.boot01.service1.StudentService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author wengqy
 * @Date 2021/1/25
 */
@RestController
@RequestMapping(value = "/student")
public class StudentController {
    @Resource
    StudentService studentService;

    @RequestMapping("/get/{id}")
   public    Student getStudentById(@PathVariable("id") int id){
        return  studentService.getStudentById(id);
    }

    @RequestMapping("/getstucla/{id}")
    public    Student getStudentClassRoomById(@PathVariable("id") int id){
        return  studentService.getStudentClassRoomById(id);
    }


    @RequestMapping("/en/{id}")
    public ResponseEntity<Student>  getStudentClassRoomById2(@PathVariable("id") int id){
        Student stu = studentService.getStudentClassRoomById(id);
        ResponseEntity<Student> entity = new ResponseEntity<>(stu, HttpStatus.OK);
        Student body = entity.getBody();
        return entity;
    }


    @RequestMapping("/ins")
    public List<Student> getStudentIns(){
        String name = "'weng','source',''";
        List<Student> studentIns = studentService.getStudentIns(name);
        return studentIns;
    }

}
